package com.zhw.service.impl;

import com.zhw.dataobject.ProductCategory;
import com.zhw.repository.ProductCategoryRepository;
import com.zhw.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/4/14.
 */
@Service    //注解，不然会空指针异常
public class CategoryServiceImpl implements CategoryService {   //service层调用DAO层（repository）类目没有给买家提供controller层

    @Autowired
    private ProductCategoryRepository repository;  //DAO层对象

    @Override
    public ProductCategory findOne(Integer categoryId) {
        return repository.findOne(categoryId);
    }

    @Override
    public List<ProductCategory> findAll() {
        return repository.findAll();   //repository自带的方法，查询所有
    }

    @Override
    public List<ProductCategory> findByCategoryIn(List<Integer> list) {
        return repository.findByCategoryTypeIn(list);
    }

    @Override
    public ProductCategory save(ProductCategory productCategory) {
        return repository.save(productCategory);
    }  //新增或更新
}
